import React from 'react';
import { Table, Button } from 'antd';

interface UserTableProps {
  users: any[];
  loading: boolean;
  onAdd: () => void;
  onEdit: (user: any) => void;
  onDelete: (user: any) => void;
  onTransfer: () => void;
}

const UserTable: React.FC<UserTableProps> = ({
  users, loading, onAdd, onEdit, onDelete, onTransfer
}) => {
  return (
    <div>
      <div style={{ marginBottom: 12 }}>
        <Button type="primary" onClick={onAdd}>新增用户</Button>
        <Button style={{ marginLeft: 8 }} onClick={onTransfer}>分配用户</Button>
      </div>
      <Table
        rowKey="id"
        loading={loading}
        dataSource={users}
        columns={[
          { title: '用户名', dataIndex: 'username' },
          { title: '姓名', dataIndex: 'name' },
          { title: '操作', render: (_: any, record: any) => (
            <>
              <Button size="small" onClick={() => onEdit(record)}>编辑</Button>
              <Button size="small" danger style={{ marginLeft: 8 }} onClick={() => onDelete(record)}>删除</Button>
            </>
          )}
        ]}
        pagination={false}
      />
    </div>
  );
};

export default UserTable; 